//
//  ORMDb.h
//  storeapp
//
//  Created by huangyi on 13-4-25.
//  Copyright (c) 2013年 ios. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Fmwk.h"

@interface SQLiteKit : NSObject

-(instancetype)initWithDatabase:(NSString*)dbfile;
+(BOOL)isSQLiteThreadSafe;

-(BOOL)open;
-(BOOL)close;
-(BOOL)reload;

-(NSArray*)getSchema;
-(NSArray*)listOfTables;
-(NSArray*)getTableSchema:(NSString*)table;
-(NSArray*)listOfFields:(NSString*)table;

-(NSUInteger)count:(NSString*)table;

-(NSInteger)insertOne:(NSDictionary*)object intoTable:(NSString*)table;
-(NSInteger)putOne:(NSDictionary*)object intoTable:(NSString*)table;
-(NSDictionary*)findOne:(NSDictionary*)where fromTable:(NSString*)table;
-(NSArray*)findAll:(NSDictionary*)where fromTable:(NSString*)table orderBy:(NSString*)order;

-(BOOL)wipe:(NSString*)table;
-(BOOL)optimize;

-(BOOL)beginTransaction;
-(BOOL)commit;
-(BOOL)rollback;

-(NSDictionary*)getRow:(NSString*)sql;
-(NSArray*)getCol:(NSString*)sql;
-(NSArray*)getAll:(NSString*)sql;
-(NSString*)getCell:(NSString*)sql;
-(BOOL)runSql:(NSString*)sql;

-(NSInteger)lastInsertID;
-(NSDictionary*)lastInsertRow:(NSString*)table;

@end

